<table width="100%"><tr><td width="20%">
<a href="../index.html">&lt; index</a><br />
<a href="index.html">&lt; 7. File parser</a><br />
<a href="parser_run.html">&lt;  7.3 Running the parser</a><br />
</td><td width="60%">
<p align="center">
=====================================<br />
7.4 Standard data types <br />
=====================================<br />
</p></td><td width="20%">
<a href="parser_custom.html">&gt; 7.5 Using custom data types</a>
</td></tr></table>
<style type="text/css">
.code { color:#444444; background-color:#EEEEEE;}
pre { color:#444444; background-color:#EEEEEE;}
table.param td { border : 1px solid #000000; }
th { background-color: #44BBFF; color: #FFFFFF }
table.none td { border : 0 }
</style>
The parser can parse natively several data types. It stores them in a generic union :<br />
<p class="code"><pre>
typedef struct {
	int nb_dices;
	int nb_faces;
	float multiplier;
	float addsub;
} TCOD_dice_t;

typedef union {
	bool b;
	char c;
	int32 i;
	float f;
	char *s;
	TCOD_color_t col;
	TCOD_dice_t dice;
	TCOD_list_t list;
	void *custom;
} TCOD_value_t;
</pre></p>
Possible types are defined by the TCOD_value_type_t enumeration :<br />
For python, remove TCOD_ : 
libtcod.TYPE_BOOL
<table class="param">
<tr><th>TCOD_value_type_t</th><th>Value in file</th><th>TCOD_value_t</th></tr>
<tr><td>TCOD_TYPE_BOOL</td><td>true<br />false</td><td>value.b == true/false</td></tr>
<tr><td>TCOD_TYPE_CHAR</td><td>decimal notation : 0 .. 255<br />
hexadecimal notation : 0x00 .. 0xff <br />
char notation : 'a' ';' ...<br />
Special characters :<br />
'\n' : carriage return (ascii 13)<br />
'\t' : tabulation (ascii 9)<br />
'\r' : line feed (ascii 10)<br />
'\\' : antislash (ascii 92)<br />
'\"' : double-quote (ascii 34)<br />
'\'' : simple quote (ascii 39)<br />
'\xHH' : hexadecimal value, same as 0xHH, HH between 0 and FF<br />
'\NNN' : octal value, NNN between 0 and 377<br />
</td><td>value.c == The corresponding ascii code</td></tr>
<tr><td>TCOD_TYPE_INT</td><td>decimal notation : -2147483648 .. 2147483647<br />hexadecimal notation : 0x0 .. 0xFFFFFFFF</td><td>value.i == the integer value</td></tr>
<tr><td>TCOD_TYPE_FLOAT</td><td>Any format parsable by atof. Examples:<br />3.14159<br />1.25E-3</td><td>value.f == the float value</td></tr>
<tr><td>TCOD_TYPE_STRING</td><td>A double-quote delimited string :<br />"This is a string"<br />Support the same special characters as TCOD_TYPE_CHAR.</td><td>value.s == the corresponding string.<br />Warning ! If you want to store this string, you have to duplicate it (with strdup) as it will be overwritten by the parser</td></tr>
<tr><td>TCOD_TYPE_COLOR</td><td>decimal notation : "16,32,64"<br />hexadecimal notation : "#102040"</td><td>value.col == the color.</td></tr>
<tr><td>TCOD_TYPE_DICE</td><td>[multiplier x] nb_dices d nb_faces [(+|-) addsub] :<br />"3d6"<br />"3d6+2"<br />"0.5x3d6-2"</td><td>value.dice == the dice components</td></tr>
<tr><td>TCOD_TYPE_VALUELISTxx</td><td>Same as TCOD_TYPE_STRING</td><td>value.s == the string value from the value list</td></tr>
<tr><td>TCOD_TYPE_LIST</td><td>[ &lt;value1&gt;,&lt;value2&gt;,... ]</td><td>value.list == the TCOD_list_t containing the elements</td></tr>
</table><br />
To define a list type, use the appropriate function (TCODParserStruct::addListProperty / TCOD_parser_add_list_property) and specify the type of the elements in the list. Lists of list are not supported.
